<?php

class UserLoginKey
{

    public static function getKey($uid)
    {
        $clientKey = TokenAuthConfig::getClientKey();
        $adminStr = GenerateEncrypt::decrypt($uid, $clientKey['user']);
        $admin = explode('|', $adminStr);
        if (!empty($admin) && isset($admin[1])) {
            return $admin;
        } else {
            return null;
        }
    }

    public static function createKey($key, $time = 0)
    {
        $clientKey = TokenAuthConfig::getClientKey();
        $now = $time ? $time : time();
        $txt = $key . '|' . dechex($now);
        $uid = GenerateEncrypt::encrypt($txt, $clientKey['user']);
        return $uid;
    }
}